﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using FuncVB;
using SAC.Elink;
using SAC.sqlHelper;
using BLL;
using SAC.Helper;
using System.Collections;

public partial class _Default : System.Web.UI.Page
{
   

    protected void Page_Load(object sender, EventArgs e)
    {
        Hashtable ht = new Hashtable();
        SAC.Helper.StrHelper sh = new StrHelper();

        ht.Add("b", "");
        ht.Add("a", "3");
       /// ht.Add("a", "1");
        ht.Add("b2", "3");
        ht.Add("c5", "4");
        ht.Add("c", "5");

        if (ht.ContainsKey("a"))
        {
            Response.Write(ht["a"]);
        }
        string s = "1,3,2,7";
        string [] ss=s.Split(',');

        string[] ss1 = sh.arraySort(ss);

        //ArrayList list = new ArrayList(ht.Keys);

        //list.Sort();

        //foreach (string skey in list)
        //{
        //    Response.Write(skey + ":");
        //    Response.Write(ht[skey]);//排序后输出
        //}

        //foreach (DictionaryEntry de in ht)
        //{
        //    //fileht为一个Hashtable实例
        //    Response.Write(de.Key + "--" + de.Value + "\n");
        //}



        //Response.Redirect("~/bgData/Zbmsg.aspx?repName=cyd");

        //Response.Redirect("~/bgData/SheetManage.aspx?repName=gl");

        //Response.Redirect(Server.UrlEncode("../ednaview.aspx?fName=WHSIS.APP:GL\\汽水系统.RTV"));

        //Response.Redirect("~/RepAnyTime/Cydrb.aspx?repName=zh");
        //Response.Redirect("~/Rep/CydnmxA.aspx?repName=gl");

        Response.Redirect("~/Rep/Cydzb.aspx?repName=gl&unit=1&repType=zr"); 
        //Response.Redirect("~/Rep/CydrbAnyTime.aspx?repName=gl");
        //Response.Redirect("~/Rep/Cydyb.aspx?repName=锅炉报表");

        //Response.Redirect("~/bgData/DLHBManger.aspx?dlType=qbb");

        //string mon = "1-3+" + Math.Abs(1 - 3).ToString();

        //string res = strHelper.Cale(mon);
        //string str = "";

        //BLL.BLLRep br = new BLLRep();

        //str =br.test();

        //Response.Write(str);

        //SAC.Helper.IniHelper ih = new IniHelper();

        //IniHelper.WriteIniData("teest", "key", "123");

        //DateTime dt = DateTime.Now;
        //double res = 0.00;

        //Func funcVB = new Func();

        ////Response.Write(dt.ToShortDateString() + dt.Day + dt.ToLocalTime());
        ////Response.Write(res.ToString("f" + "2"));



        ////string DL1 = "";
        ////string ID1 = "fdj1zxyg";
        ////string bm = "";
        ////object sDate = dt.ToShortDateString() + " " + "00:00:00";
        ////object eDate = dt.ToShortDateString() + " " + dt.Hour + ":00:00";

        ////funcVB.getdl(DL1, ID1, sDate, eDate, bm);


        ////        Response.Write(DL1);

        ////当月第一天
        //DateTime FirstDay = DateTime.Now.AddDays(-DateTime.Now.Day + 1);
        //Response.Write(FirstDay.ToString());
        //Response.Write(FirstDay.ToShortDateString());

        ////最后一天
        //DateTime LastDay = DateTime.Now.AddMonths(1).AddDays(-DateTime.Now.Day);
        //Response.Write(LastDay.ToString());

        ////上个月第一天
        //Response.Write("\n 上个月第一天：" + this.FirstDayOfPreviousMonth(DateTime.Now).ToString());
        ////上个月最后一天        
        //Response.Write("\n 上个月最后一天:" + this.LastDayOfPrdviousMonth(DateTime.Now).ToString());

        ////Response.Write(Convert.ToDateTime("2011-1-1 23:58:23").AddMonths(-1).ToString());
        ////Response.Write(DateTime.Now.AddYears(-1).ToLocalTime());

        ////Response.Write(DateTime.Now.ToLocalTime());
        ////Response.Write(DateTime.Now.AddMonths(0 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01"));
        ////Response.Write(DateTime.Parse(DateTime.Now.AddMonths(3 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01")).AddDays(-1).ToShortDateString());

        //DateTime dt1 = DateTime.Parse("2011-08-01");



        //string r = this.DateDiff(dt1, DateTime.Now.Date);

        //string[] numDate = new string[int.Parse(r) + 1];

        //for (int i = 0; i < int.Parse(r) + 1; i++)
        //{
        //    Response.Write("\r\n 日期 :" + dt1.AddDays(+i).ToShortDateString());
        //}
        //Response.Write(numDate.Length);
        //Response.Write("/r/n++++" + r);
        //int k = dt.Hour - 1;
        //Response.Write("=====" + dt.ToShortDateString() + " " + k + "00:00");
        //Response.Write("========================="); 
        //Response.Write(this.FirstDayOfPreviousMonth(DateTime.Now.Date).ToShortDateString() + " " + "00:00:00"); //上月第一天

        //Response.Write(this.FirstDayOfPreviousMonth(DateTime.Now.Date).AddYears(-1).ToShortDateString() + " 00:00:00");

        //string p = "WHSIS.CALC.ZBTJH007";
        //string t = "2011-09-20";
        //DBedna db = new DBedna();
        //Response.Write("sdfafsadfa" + db.GetHisValueByTag(p, t));

        //Elink ek = new Elink();

        //ek.GetHisValue()

        //Response.Redirect("bgData/Zbmsg.aspx?repName=锅炉报表");

        //DateTime dt = DateTime.Parse("2012-2-20");

        //string v = this.GetInceDay(dt);
        // l = this.GetEndDay(dt);
        //string errMsg = "";

        //string sql = "select sum(统计值) from test2 where (统计ID = 'ZBTJ208') and 时间 between '2011-1-19 0:00:00' and  '2011-1-20 23:59:59' and 标记=1 and 机组=2";

        //object value = DBsql.RunSingle(sql, out errMsg);

        //string s = value.ToString();
        //if (value == null)
        //{
        //    Response.Write("OK");
        //}

        //if (value == "")
        //{
        //    Response.Write("meiy");
        //}


        //BLL.BLLRep br = new BLLRep();


        //  bool falg = br.Test();


    }

    private void test()
    {
        //     If DateDiff("m", strtime3, Now) > 0 Then
        //    strMEnd = DateAdd("d", -1, Year(strtime3) & "-" & Month(strtime3) & "-01")
        // Else
        //    strMEnd = DateAdd("d", -1, Date)
        // End If

        //Select Case Month(strtime3)
        //       Case 1, 2, 3
        //            If Month(Date) > 3 Or Year(Date) > Year(strtime3) Then
        //               strJEnd = Year(strtime3) & "-3-31"
        //            Else
        //               strJEnd = DateAdd("d", -1, Date)
        //            End If
        //       Case 4, 5, 6
        //            If Month(Date) > 6 Or Year(Date) > Year(strtime3) Then
        //               strJEnd = Year(strtime3) & "-6-30"
        //            Else
        //               strJEnd = DateAdd("d", -1, Date)
        //            End If
        //       Case 7, 8, 9
        //            If Month(Date) > 9 Or Year(Date) > Year(strtime3) Then
        //               strJEnd = Year(strtime3) & "-9-30"
        //            Else
        //               strJEnd = DateAdd("d", -1, Date)
        //            End If
        //       Case 10, 11, 12
        //            If Year(Date) > Year(strtime3) Then
        //               strJEnd = Year(strtime3) & "-12-31"
        //            Else
        //               strJEnd = DateAdd("d", -1, Date)
        //            End If
        //       End Select


        // If DateDiff("y", strtime3, Now) > 0 Then
        //    strYEnd = DateAdd("d", -1, Year(strtime3) & "-01-01 00:00:00")
        // Else
        //    strYEnd = DateAdd("d", -1, Date)
        // End If

        //sql = "SELECT * FROM ADMINISTRATOR.壁温测点信息表 where 类型='水冷壁'";

        //DataTable dt = DBdb2.RunDataTable(sql, out errMsg);

        //int k = 0;

        //string tt = "";

        //for (int i = 0; i < dt.Rows.Count; i++)
        //{
        //    k = 1 + i;

        //    if (dt.Rows[i]["测点描述"].ToString().Contains("（前）"))
        //        tt = "水冷壁前";
        //    else if (dt.Rows[i]["测点描述"].ToString().Contains("（后）"))
        //        tt = "水冷壁后";
        //    else if (dt.Rows[i]["测点描述"].ToString().Contains("（左侧）"))
        //        tt = "水冷壁左";
        //    else if (dt.Rows[i]["测点描述"].ToString().Contains("（右侧）"))
        //        tt = "水冷壁右";

        //    sql = "update ADMINISTRATOR.壁温测点信息表 set 编号="+k+", typeinfo='"+tt+"'";

        //    DBdb2.
        //}
    }

    private string DateDiff(DateTime DateTime1, DateTime DateTime2)
    {
        string dateDiff = null;
        TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
        TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
        TimeSpan ts = ts1.Subtract(ts2).Duration();
        dateDiff = ts.Days.ToString();// +"天" + ts.Hours.ToString() + "小时" + ts.Minutes.ToString() + "分钟" + ts.Seconds.ToString() + "秒";
        return dateDiff;
    }

    /// <summary>
    /// 取得上个月第一天
    /// </summary>
    /// <param name="datetime">要取得上个月第一天的当前时间</param>
    /// <returns></returns>
    private DateTime FirstDayOfPreviousMonth(DateTime datetime)
    {
        return datetime.AddDays(1 - datetime.Day).AddMonths(-1);
    }

    /// <summary>
    /// 取得上个月的最后一天
    /// </summary>
    /// <param name="datetime">要取得上个月最后一天的当前时间</param>
    /// <returns></returns>
    private DateTime LastDayOfPrdviousMonth(DateTime datetime)
    {
        return datetime.AddDays(1 - datetime.Day).AddDays(-1);
    }



}
